/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Frame;

import jPlay.Sprite;
import java.util.logging.Level;
import java.util.logging.Logger;
import ufc.quixada.es.controlador.ControladorJogador;

/**
 *
 * @author wagner
 */
public class EscolherPersonagem extends javax.swing.JFrame {
/*Escolha = 0 vermelhor
  Escolha = 1 preto
  Escolha = 2 verde
  Escolha = 3 Amarelo*/
    
ControladorJogador controladorJogador = new ControladorJogador(3);  

int numID=1;
String escolha;
boolean amarelo;
boolean vermelhor;
boolean preto;
boolean verde;
    /**
     * Creates new form EscolherPersonagem
     */
    public EscolherPersonagem() {
        initComponents();
        jLabelInserirNome.setVisible(false);
        nomeUsuario.setVisible(false);
        jButtonCadastrar.setVisible(false);
           
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButtonAvatarPreto = new javax.swing.JButton();
        jButtonAvatarVermelho = new javax.swing.JButton();
        jButtonAvatarAmarelo = new javax.swing.JButton();
        jButtonAvatarVerde = new javax.swing.JButton();
        nomeUsuario = new javax.swing.JTextField();
        jButtonCadastrar = new javax.swing.JButton();
        jLabelInserirNome = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabelFundoAmarelo = new javax.swing.JLabel();
        jLabelFundoPreto = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jButtonVoltar = new javax.swing.JButton();
        jLabelNomeEscolherPersonagem = new javax.swing.JLabel();
        jLabelFundoTrasparente = new javax.swing.JLabel();
        jLabelFundo = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setPreferredSize(new java.awt.Dimension(1500, 750));
        getContentPane().setLayout(null);

        jButtonAvatarPreto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/angry-bird-black-iconTAB.png"))); // NOI18N
        jButtonAvatarPreto.setBorderPainted(false);
        jButtonAvatarPreto.setContentAreaFilled(false);
        jButtonAvatarPreto.setDefaultCapable(false);
        jButtonAvatarPreto.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/angry-bird-black-iconmenor.png"))); // NOI18N
        jButtonAvatarPreto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAvatarPretoActionPerformed(evt);
            }
        });
        getContentPane().add(jButtonAvatarPreto);
        jButtonAvatarPreto.setBounds(310, 280, 130, 100);

        jButtonAvatarVermelho.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/angry-bird-iconTAB.png"))); // NOI18N
        jButtonAvatarVermelho.setBorderPainted(false);
        jButtonAvatarVermelho.setContentAreaFilled(false);
        jButtonAvatarVermelho.setDefaultCapable(false);
        jButtonAvatarVermelho.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/angry-bird-icon.menor.png"))); // NOI18N
        jButtonAvatarVermelho.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAvatarVermelhoActionPerformed(evt);
            }
        });
        getContentPane().add(jButtonAvatarVermelho);
        jButtonAvatarVermelho.setBounds(480, 280, 120, 100);

        jButtonAvatarAmarelo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/angry-bird-yellow-iconTAB.png"))); // NOI18N
        jButtonAvatarAmarelo.setBorderPainted(false);
        jButtonAvatarAmarelo.setContentAreaFilled(false);
        jButtonAvatarAmarelo.setDefaultCapable(false);
        jButtonAvatarAmarelo.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/angry-bird-yellow-iconmenor.png"))); // NOI18N
        jButtonAvatarAmarelo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAvatarAmareloActionPerformed(evt);
            }
        });
        getContentPane().add(jButtonAvatarAmarelo);
        jButtonAvatarAmarelo.setBounds(660, 280, 120, 100);

        jButtonAvatarVerde.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/angry-bird-green-iconTAB.png"))); // NOI18N
        jButtonAvatarVerde.setBorderPainted(false);
        jButtonAvatarVerde.setContentAreaFilled(false);
        jButtonAvatarVerde.setDefaultCapable(false);
        jButtonAvatarVerde.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/angry-bird-green-iconmenor.png"))); // NOI18N
        jButtonAvatarVerde.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAvatarVerdeActionPerformed(evt);
            }
        });
        getContentPane().add(jButtonAvatarVerde);
        jButtonAvatarVerde.setBounds(840, 280, 110, 110);

        nomeUsuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nomeUsuarioActionPerformed(evt);
            }
        });
        getContentPane().add(nomeUsuario);
        nomeUsuario.setBounds(450, 500, 430, 27);

        jButtonCadastrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/Cadastrar_1.png"))); // NOI18N
        jButtonCadastrar.setBorderPainted(false);
        jButtonCadastrar.setContentAreaFilled(false);
        jButtonCadastrar.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/BotãoCadastrarIcon.png"))); // NOI18N
        jButtonCadastrar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/Cadastrar_1.png"))); // NOI18N
        jButtonCadastrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCadastrarActionPerformed(evt);
            }
        });
        getContentPane().add(jButtonCadastrar);
        jButtonCadastrar.setBounds(510, 550, 250, 60);

        jLabelInserirNome.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/nomeInserirNome.png"))); // NOI18N
        getContentPane().add(jLabelInserirNome);
        jLabelInserirNome.setBounds(550, 460, 260, 40);

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/FundoVermelhor.png"))); // NOI18N
        jLabel2.setText("jLabel2");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(460, 280, 170, 110);

        jLabelFundoAmarelo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/FundoAmarelo.png"))); // NOI18N
        jLabelFundoAmarelo.setText("jLabel2");
        getContentPane().add(jLabelFundoAmarelo);
        jLabelFundoAmarelo.setBounds(630, 280, 180, 110);

        jLabelFundoPreto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/FundoPreto.png"))); // NOI18N
        jLabelFundoPreto.setText("jLabel2");
        getContentPane().add(jLabelFundoPreto);
        jLabelFundoPreto.setBounds(300, 280, 160, 110);

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/iniciarJogoPEditado2.png"))); // NOI18N
        jButton1.setBorderPainted(false);
        jButton1.setContentAreaFilled(false);
        jButton1.setDefaultCapable(false);
        jButton1.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/IniciarJogoGEditado.png"))); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1);
        jButton1.setBounds(1020, 630, 230, 70);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/FundoVerde_1.png"))); // NOI18N
        jLabel1.setText("jLabel1");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(810, 280, 170, 110);

        jButtonVoltar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/BotãoVoltarPerqueno.png"))); // NOI18N
        jButtonVoltar.setBorderPainted(false);
        jButtonVoltar.setContentAreaFilled(false);
        jButtonVoltar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/VoltarRgrande.png"))); // NOI18N
        jButtonVoltar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonVoltarActionPerformed(evt);
            }
        });
        getContentPane().add(jButtonVoltar);
        jButtonVoltar.setBounds(100, 620, 200, 80);

        jLabelNomeEscolherPersonagem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/NomeEscolherPersonagem.png"))); // NOI18N
        getContentPane().add(jLabelNomeEscolherPersonagem);
        jLabelNomeEscolherPersonagem.setBounds(390, 200, 550, 66);

        jLabelFundoTrasparente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/QuaseFundo.png"))); // NOI18N
        getContentPane().add(jLabelFundoTrasparente);
        jLabelFundoTrasparente.setBounds(270, 170, 730, 460);

        jLabelFundo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/Fundo1.png"))); // NOI18N
        getContentPane().add(jLabelFundo);
        jLabelFundo.setBounds(0, -100, 1410, 950);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonAvatarVermelhoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAvatarVermelhoActionPerformed
        vermelhor=false; 
        escolha = "vermelho.png";
        jLabelInserirNome.setVisible(true); 
        jButtonAvatarVermelho.setVisible(vermelhor);
        nomeUsuario.setVisible(true);
        jButtonCadastrar.setVisible(true); 
      
    }//GEN-LAST:event_jButtonAvatarVermelhoActionPerformed

    private void nomeUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nomeUsuarioActionPerformed

      
    }//GEN-LAST:event_nomeUsuarioActionPerformed

    private void jButtonAvatarPretoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAvatarPretoActionPerformed
      preto = false;
      escolha="preto.png";
       jLabelInserirNome.setVisible(true);
       jButtonAvatarPreto.setVisible(preto);
       nomeUsuario.setVisible(true);
       jButtonCadastrar.setVisible(true);
     
    }//GEN-LAST:event_jButtonAvatarPretoActionPerformed

    private void jButtonAvatarAmareloActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAvatarAmareloActionPerformed
       amarelo = false;
       escolha = "amarelo.png";
       jLabelInserirNome.setVisible(true);
       jButtonAvatarAmarelo.setVisible(amarelo);
       nomeUsuario.setVisible(true);
       jButtonCadastrar.setVisible(true);
 
    }//GEN-LAST:event_jButtonAvatarAmareloActionPerformed

    private void jButtonAvatarVerdeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAvatarVerdeActionPerformed
      verde=false;
      escolha = "verde.png";
       jLabelInserirNome.setVisible(true);
       jButtonAvatarVerde.setVisible(verde);
       nomeUsuario.setVisible(true);
       jButtonCadastrar.setVisible(true);       

    }//GEN-LAST:event_jButtonAvatarVerdeActionPerformed

    private void jButtonCadastrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCadastrarActionPerformed

        jLabelInserirNome.setVisible(false);
        nomeUsuario.setVisible(false);
        jButtonCadastrar.setVisible(false);
    try {
        controladorJogador.criarJogador(nomeUsuario.getText(), escolha,numID);
        System.out.println(numID);
        numID+=1;
         } catch (Exception ex) {
        Logger.getLogger(EscolherPersonagem.class.getName()).log(Level.SEVERE, null, ex);
    }
        nomeUsuario.setText(null);
        escolha="";
        
    }//GEN-LAST:event_jButtonCadastrarActionPerformed

    private void jButtonVoltarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonVoltarActionPerformed
      
        
      Inicial inicial = new Inicial();
      inicial.setVisible(true);
    }//GEN-LAST:event_jButtonVoltarActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
      TesteTeste t = null;
    try {
        t = new TesteTeste(controladorJogador);
    } catch (Exception ex) {
        Logger.getLogger(EscolherPersonagem.class.getName()).log(Level.SEVERE, null, ex);
    }
      t.setVisible(true);
      this.dispose();
     // try {
        // TODO add your handling code here:
       //Teste a= new Teste(controladorJogador);
    //} catch (Exception ex) {
     // Logger.getLogger(EscolherPersonagem.class.getName()).log(Level.SEVERE, null, ex);
   //}
    }//GEN-LAST:event_jButton1ActionPerformed

       
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(EscolherPersonagem.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(EscolherPersonagem.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(EscolherPersonagem.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(EscolherPersonagem.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        java.awt.EventQueue.invokeLater(new Runnable() {
          public void run() {
                
     
        
           }
        });

        /* Create and display the form */
       
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButtonAvatarAmarelo;
    private javax.swing.JButton jButtonAvatarPreto;
    private javax.swing.JButton jButtonAvatarVerde;
    private javax.swing.JButton jButtonAvatarVermelho;
    private javax.swing.JButton jButtonCadastrar;
    private javax.swing.JButton jButtonVoltar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabelFundo;
    private javax.swing.JLabel jLabelFundoAmarelo;
    private javax.swing.JLabel jLabelFundoPreto;
    private javax.swing.JLabel jLabelFundoTrasparente;
    private javax.swing.JLabel jLabelInserirNome;
    private javax.swing.JLabel jLabelNomeEscolherPersonagem;
    private javax.swing.JTextField nomeUsuario;
    // End of variables declaration//GEN-END:variables
}
